<template>
  <div id="app">
    <transition :name="transitionName">
      <router-view></router-view>
    </transition>

    <van-tabbar
      route
      v-model="$route.meta.active"
      active-color="#ee0a24"
      v-if="$route.meta.isTabber"
    >
      <van-tabbar-item to="/home" icon="home-o">发现</van-tabbar-item>
      <van-tabbar-item to="/cloud" icon="service">云村</van-tabbar-item>
      <van-tabbar-item to="/user" icon="user-circle-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data() {
    return {
      // animate: "",
      transitionName:''
    };
  },
  watch: {
    $route(to, from) {
      //如果to索引大于from索引,判断为前进状态,反之则为后退状态
      // console.log(to, "to");
      // console.log(from, "from");
      if (to.path === '/songdetail') {
        //设置动画名称
        this.transitionName = "slide-left";
      }else{
        this.transitionName = ''
      }
    },
  },
};
</script>
<style lang="less">
* {
  margin: 0;
  padding: 0;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}
.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
  will-change: transform;
  transition: all 500ms;
  position: absolute;
}

.slide-right-enter {
  opacity: 0;
  transform: translate3d(-100%, 0, 0);
}

.slide-right-leave-active {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}

.slide-left-enter {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}

.slide-left-leave-active {
  opacity: 0;
  transform: translate3d(-100%, 0, 0);
}
</style>
